import java.net.*;
import java.io.*;

public
class SMSIdea
{
	protected String numFrom;
	protected String numTo;
	protected String text;
	public SMSIdea(String numFrom, String numTo, String text)
	{
		this.numFrom = numFrom;
		this.numTo = numTo;
		this.text = text;
	}
	public void send()
	throws Exception
	{
		if (numTo.length() < 9){
			throw new Exception("Unsupported phone number.");
		}
		String string;
		SMSDate date = new SMSDate();
		string = "SENDER=" + numFrom;
		string += "&RECIPIENT=" + numTo;
		string += "&VALIDITY_PERIOD=24";
		string += "&DELIVERY_DATE=" + date.dzien;
		string += "&DELIVERY_MONTH=" + date.miesiac;
		string += "&DELIVERY_YEAR=" + date.rok;
		string += "&DELIVERY_HOUR=" + date.godzina;
		string += "&DELIVERY_MIN=" + date.minuta;
		string += "&SHORT_MESSAGE=" + text;
		string += "&SUBMIT=Wy%B6lij";
		
		try{
			URL url = new URL("http://sms.idea.pl/sendsms.asp?" + string);
			InputStream inp = url.openStream();
		BufferedReader d  = new BufferedReader(new InputStreamReader(inp));
			int i = 0;
			String s1, s2 = null;
			while((s1 = d.readLine()) != null){
				s2 += s1;
			}
			//System.out.println(s2);
		}
		catch(MalformedURLException e){
			System.out.println("Bdne zapytanie: " + e);
		}
		catch(IOException e){
			System.out.println("Bd IO: " + e);
		}
	}
}
